package com.jysz.certificate.persistence.model.core;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.jysz.certificate.persistence.enums.AttachmentType;
import com.jysz.certificate.persistence.model.system.User;
import com.jysz.webcore.ssh.entity.AbstractBaseEntity;

/**
 * 附件
 * @author xuxiaolong
 */
@Entity
@Table(name="core_attachment_")
@org.hibernate.annotations.Entity
public class Attachment extends AbstractBaseEntity<Long> {

	
	private static final long serialVersionUID = -5575988883064685459L;
	
	/** 附件名*/
	private String name;
	
	/** 存放路径*/
	private String path;
	
	/** 附件类型*/
	private AttachmentType type;
	
	/** 关联对象ID*/
	private Long objId;
	
	/** 上传时间*/
	private Date uploadDate;

	/** 上传人*/
	private User uploadUser;

	@Column(name="_name",nullable=false,columnDefinition="varchar(255)")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="_path",nullable=false,columnDefinition="varchar(255)")
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Column(name="_type",nullable=false,columnDefinition="int(11)")
	@Enumerated(EnumType.ORDINAL)
	public AttachmentType getType() {
		return type;
	}

	public void setType(AttachmentType type) {
		this.type = type;
	}

	@Column(name="_obj_id",nullable=false,columnDefinition="bigint(20)")
	public Long getObjId() {
		return objId;
	}

	public void setObjId(Long objId) {
		this.objId = objId;
	}

	@Column(name="_upload_date")
	public Date getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(Date uploadDate) {
		this.uploadDate = uploadDate;
	}

	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.REFRESH)  
	@JoinColumn(name = "_upload_user_id",insertable=true, updatable=true,columnDefinition="bigint(20)")
	public User getUploadUser() {
		return uploadUser;
	}

	public void setUploadUser(User uploadUser) {
		this.uploadUser = uploadUser;
	}
	
}
